package com.cratos.xxgram.platf.facade;

import javax.annotation.Resource;

import org.redkale.boot.Application;
import org.redkale.net.http.RestMapping;
import org.redkale.net.http.RestService;
import org.redkale.service.RetResult;
import org.redkale.util.AnyValue;
import org.redkale.util.Comment;

import com.cratos.xxgram.platf.base.BaseService;
import com.cratos.xxgram.platf.base.RetCodes;
import com.cratos.xxgram.platf.base.UserInfo;
import com.cratos.xxgram.platf.friend.FriendService;
import com.cratos.xxgram.platf.friend.FriendShip;
import com.cratos.xxgram.platf.group.GroupServiceWs;
import com.cratos.xxgram.platf.user.UserService;
public class OssService extends BaseService {

	@Resource
	private FriendService friendService;
	
	@Resource
	private GroupServiceWs groupService;
	
	@Resource
	private UserService userService;
	
	@Override
	public void init(AnyValue config) {
		super.init(config);
	}
	
	@Comment("更新用户在线状态  注销  踢人 账号停用或者启用")
	public RetResult updateUserStatus(int userid, short status) {
		return userService.updateStatus(userid, status);
	}
	
	@Comment("重置密码")
	public RetResult resetUserPwdByAdmin(int userid) {
		return userService.resetPwdByAdmin(userid);
	}
	
	@Comment("销毁账号")
	public RetResult destroyAccount(int userid) {
		return userService.destroyAccount(source.find(UserInfo.class, userid));
	}

	@Comment("更新好友关系黑名单  添加或者移出黑名单  "
			+ "	好友列表 关系 10 被加入了黑名单 20 正常好友")
	public RetResult updateBlackList(UserInfo userInfo, FriendShip bean) {
		// 校验参数有效性
		if (userInfo.getUserid() == 0 
					|| bean.getFriendid() == 0) {
			return RetCodes.retResult(RetCodes.RET_PARAMS_ILLEGAL);
		}
		
		if (bean.getRelationship() != FriendShip.RELATION_SHIP_NORMAL && 
					bean.getRelationship() != FriendShip.RELATION_SHIP_BLACKLIST) {
			return RetCodes.retResult(RetCodes.RET_PARAMS_ILLEGAL);
		}
		return friendService.updateBlackList(userInfo, bean);
	}
	
	@Comment("删除好友")
	public RetResult removeFriend(UserInfo userInfo, int friendId) {
		return friendService.delFriend(userInfo, friendId);
	}
	
	@Comment("踢除群组")
    public RetResult removeUserFromGroup(UserInfo userInfo, int groupId) {
        return groupService.removeUserFromGroup(userInfo,  groupId);
    }
	
	@Comment("修改群配置")
    public RetResult updateSystemSetting(UserInfo userInfo, int groupid, int index, int value) {
        return groupService.updateSystemSetting(userInfo, groupid, index, value);
    }
	
	 @Comment("解散")
    public RetResult dismissGroup(int groupId) {
        return groupService.dismissGroup(groupId);
    }
}
